package LeetCode.leetcode452;

import java.util.*;

class Solution {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, (a, b) -> {
            return (a[0] - b[0]);
        });
        if (points.length == 0) return 0;
        if (points.length == 1) return 1;
        int res = 1;
        int minRight = points[0][1];
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] > minRight) {
                res++;
                minRight = points[i][1];
            }else {
                minRight = Math.min(points[i][1],minRight);
            }
        }

        return res;
    }
}